var pictures = document.getElementsByClassName("preview");
var w = pictures[0].width;
var h = 0.5625 * w;
for (var index = 0; index < pictures.length; index++) {
  pictures[index].height = h;
}